<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则方法test</title>
</head>
<body>
    <input type="text" name="email">
    <span></span>
</body>
<script>
    /*
        正则的test方法 如果字符串与正则能够匹配返回true 否则返回false
        常常是用于验证判断上 因为会返回一个清晰的布尔值
    */
    const email = document.querySelector('input')
    const span = document.querySelector('span')
    const reg = /^\w+@(qq|163|soho)\.(com|cn)$/i
    email.addEventListener('keyup',function(){
        console.log(this.value)
        span.innerHTML = reg.test(this.value)?'正确':'错误'
    })
</script>
</html>